package com.yunbiji.demo.controller;

import com.yunbiji.demo.entity.CnNotebook;
import com.yunbiji.demo.service.CnNotebookService;
import com.yunbiji.demo.util.NoteResult;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * (CnNotebook)表控制层
 *
 * @author makejava
 * @since 2021-06-02 08:41:43
 */
@Controller
@RequestMapping(value = {"cnNotebook","/"})
public class CnNotebookController {


    @Resource
    private CnNotebookService cnNotebookService;


//    @RequestMapping("/findNormal.do")
//    @ResponseBody
//    public NoteResult<CnNotebook> execute3(String notebookId){
//        return null;
//    }
//
//    @RequestMapping("/findSpecial.do")
//    @ResponseBody
//    public NoteResult<CnNotebook> execute4(String notebookId){
//        return null;
//    }

    @GetMapping("selectOne")
    public CnNotebook selectOne(String id) {
        return this.cnNotebookService.queryById(id);
    }


    @RequestMapping("/add.do")
    @ResponseBody
    public NoteResult<CnNotebook> execute(String userId, String title){
        NoteResult<CnNotebook> result = cnNotebookService.addBook(userId, title);
        return result;
    }

    @RequestMapping("/loadBooks.do")
    @ResponseBody
    public NoteResult<List<CnNotebook>> execute(String userId){
        NoteResult<List<CnNotebook>> result = cnNotebookService.loadUserBook(userId);
        return result;
    }


}